

<%= image_tag("icons/spinner.gif",
              :align => "absmiddle",
              :border => 0,
              :id => "spinner",
              :style =>"display: none;" ) %>

<h2>Administration</h2>
  <% if flash[:alert] %>
      <div class="flash error"><%= flash[:alert] %></div>
  <% end %>
  <% if flash[:notice] %>
      <div class="flash notice"><%= flash[:notice] %></div>
  <% end %>
<div class="intro-cartasur">
  <h3>Cartasur Users</h3>
  <%= t 'cartasur.admin.users.view' %>
</div>
<br />

<table>
<tr>
  <td > <%= t 'cartasur.admin.users.chooseusertype' %></td>
  <td>

    <%= link_to "Cartasur users", cartasur_users_path()  %> |
    <%= link_to "Admins", cartasur_users_path( :l=>"admin")  %> |
    <%= link_to "Partners", cartasur_users_path(:l=>"partner")  %>
  </td>
</tr>
</table>

<hr />
<% unless @cusers.nil? %>
<%= will_paginate @cusers  %>
<table cellpadding="5" cellspacing="10" id="zebra-rows">
  <th>User </th>
  <th>Email </th>
  <th>Finished protocols</th>
  <th> </th>
  <% count = 0 #for highlighting rows %>
  <% @cusers.each do |user| %>

      <tr <%= "class=odd" if count.odd? %>>
        <td><%= link_to user.login, edit_cartasur_user_path(user) %> </td>
        <td><%=  user.email %> </td>
        <td><%= user.completed_protocols.try(:size) || "0" %></td>
        <td>
          <%= link_to("protocols", showobjectives_cartasur_user_path(user)) %>
          <!--| <a href="/cartasur/api/objectives.xml?key=<%= user.salt %>">xml</a>-->
        </td>
      </tr>

      <% count = count + 1 %>
  <% end %>
<% else %>
  <p><%= t 'cartasur.admin.users.nousers' %></p>
<% end %>
</table>

<br />
<% if admin? %>
   <p><a href="<%= new_cartasur_user_path %>" ><%= t 'cartasur.admin.users.addnewuser' %></a></p>
<% end %>